package com.eastfair.projectcore.service.impl;

import com.eastfair.projectcore.dao.MsgTemplateMapper;
import com.eastfair.projectcore.entity.MsgTemplate;
import com.eastfair.projectcore.service.MsgTemplateService;
import com.eastfair.boot.service.SuperServiceImpl;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;

/**
 * <p>
 * 业务实现类
 * 消息模板表（短信、邮件、站内信）
 * </p>
 *
 * @author liuxiaobai
 * @date 2021-08-04
 */
@Slf4j
@Service
public class MsgTemplateServiceImpl extends SuperServiceImpl<MsgTemplateMapper, MsgTemplate> implements MsgTemplateService {


    /**************sharding 分库分表操作 *****************/
    @Override
    public boolean updateByIdOfShard(MsgTemplate entity) {
        UpdateWrapper<MsgTemplate> updateWrapper = new UpdateWrapper<>();
        //可将指定字段更新为null
        updateWrapper.lambda().eq(MsgTemplate::getProjectId, entity.getProjectId()).eq(MsgTemplate::getId, entity.getId());
        entity.setProjectId(null);
        //删除缓存
        //delCache(entity);
        return SqlHelper.retBool(this.getBaseMapper().update(entity, updateWrapper));
    }

}
